<html>
<head><meta charset="utf-8"><title>let _ = x pattern · t-compiler/wg-rfc-2229 · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/index.html">t-compiler/wg-rfc-2229</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html">let _ = x pattern</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="215279130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215279130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215279130">(Nov 02 2020 at 04:44)</a>:</h4>
<p>I updated the liveness analysis and realized that <code>let _ = x</code> pattern doesn't seem to compile when the feature gate is set. </p>
<p>Very simple test file: <a href="http://csclub.uwaterloo.ca/~a52arora/test_suite/test.rs">http://csclub.uwaterloo.ca/~a52arora/test_suite/test.rs</a><br>
Backtrace: <a href="http://csclub.uwaterloo.ca/~a52arora/test_suite/mir_build_err_test">http://csclub.uwaterloo.ca/~a52arora/test_suite/mir_build_err_test</a><br>
(Just a side note: We would now warn for <code>let _ = x</code> which could cause builds to fail if the user has treat warn as err, so that would need to be considered in migrations as well.)</p>
<p>The error happens here: <a href="https://github.com/sexxi-goose/rust/blob/min_capture/compiler/rustc_mir_build/src/build/mod.rs#L362">https://github.com/sexxi-goose/rust/blob/min_capture/compiler/rustc_mir_build/src/build/mod.rs#L362</a></p>
<p>One of the things in the backtrace is: <a href="https://github.com/sexxi-goose/rust/blob/min_capture/compiler/rustc_mir_build/src/build/block.rs#L132">https://github.com/sexxi-goose/rust/blob/min_capture/compiler/rustc_mir_build/src/build/block.rs#L132</a></p>
<p>From what I understand the issue is probably around handling the <code>let _ = x</code>, possibly because x isn't being captured. </p>
<p>I'm not too familiar with that part of the codebase, so I'm not sure what are the best ways to deal with this issue.</p>



<a name="215279207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215279207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215279207">(Nov 02 2020 at 04:46)</a>:</h4>
<p>Some thoughts</p>
<ul>
<li>Update THIR so that such statements within closures are removed if the feature gate is enabled (not sure what would be the impact of doing so)</li>
<li>or Update the statemen handler in MIR build to ignore such statements (not sure how easy would it be to propagate that we are handling things inside a closure)</li>
<li>or capture x in such patterns by updating ExprUseVisitor</li>
</ul>



<a name="215279210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215279210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215279210">(Nov 02 2020 at 04:47)</a>:</h4>
<p>(Sorry I kind of messed up the testing last week which resulted in the feature gate not being set when the tests were being run, inturn resulting in missing this edge case)</p>



<a name="215317149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215317149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215317149">(Nov 02 2020 at 13:22)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> can you clarify what sort of error we are getting?</p>



<a name="215317166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215317166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215317166">(Nov 02 2020 at 13:22)</a>:</h4>
<p>oh, I guess it's an ICE</p>



<a name="215317214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215317214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215317214">(Nov 02 2020 at 13:23)</a>:</h4>
<p>I see, hmm, I think the issue is that the <em>THIR</em> still includes <code>let _ = x</code> even though, ultimately, MIR will treat it as a kind of no-op?</p>



<a name="215317218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215317218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215317218">(Nov 02 2020 at 13:23)</a>:</h4>
<p>It occurs to me that this may not be entirely true</p>



<a name="215317225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215317225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215317225">(Nov 02 2020 at 13:23)</a>:</h4>
<p>We may include some kind of dummy read</p>



<a name="215317283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215317283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215317283">(Nov 02 2020 at 13:24)</a>:</h4>
<p>I am <em>somewhat</em> inclined to have <code>let _ = x</code> be treated as potentially using <code>x</code> if that is indeed the case</p>



<a name="215371276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215371276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215371276">(Nov 02 2020 at 20:06)</a>:</h4>
<p>If I understand this correctly we are building MIR <a href="https://github.com/sexxi-goose/rust/blob/min_capture/compiler/rustc_mir_build/src/build/block.rs#L100-L137">here</a>. We don't exactly disregard if we see Patkind::Wild here. </p>
<p>On the surface, the code in mir_build is fairly generic, so making changes to handle this case for closure would require pipelining some context. <br>
I'm assuming it's to handle  wildcards in destructure patterns.</p>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215317283">said</a>:</p>
<blockquote>
<p>I am <em>somewhat</em> inclined to have <code>let _ = x</code> be treated as potentially using <code>x</code> if that is indeed the case</p>
</blockquote>
<p>If I understand this correctly we want x to be a capture.</p>



<a name="215383254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383254">(Nov 02 2020 at 21:44)</a>:</h4>
<p>So <span class="user-mention" data-user-id="281950">@Aman Arora</span> most notably we invoke <a href="https://github.com/sexxi-goose/rust/blob/min_capture/compiler/rustc_mir_build/src/build/block.rs#L132"><code>expr_into_pattern</code></a></p>



<a name="215383401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383401">(Nov 02 2020 at 21:44)</a>:</h4>
<p>which converts the initializer into a place</p>



<a name="215383407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383407">(Nov 02 2020 at 21:45)</a>:</h4>
<p>Note that this code gets an error</p>



<a name="215383440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383440">(Nov 02 2020 at 21:45)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">v</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="o">*</span><span class="n">p</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="215383452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383452">(Nov 02 2020 at 21:45)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=fad511a429badcd3d88961d59a9b6cf7">playground</a></p>



<a name="215383473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383473">(Nov 02 2020 at 21:45)</a>:</h4>
<p>er wait</p>



<a name="215383498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383498">(Nov 02 2020 at 21:45)</a>:</h4>
<p>but <code>let _ = v</code> doesn't</p>



<a name="215383516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383516">(Nov 02 2020 at 21:45)</a>:</h4>
<p>(which is the point)</p>



<a name="215383528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383528">(Nov 02 2020 at 21:45)</a>:</h4>
<p>tricky :)</p>



<a name="215383552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383552">(Nov 02 2020 at 21:46)</a>:</h4>
<p>anyway what we could do</p>



<a name="215383586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383586">(Nov 02 2020 at 21:46)</a>:</h4>
<p>(regardless)</p>



<a name="215383651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383651">(Nov 02 2020 at 21:46)</a>:</h4>
<p>is to modify the <code>ExprUseVisitor</code> to add a <code>borrow</code> callback on the initializer of a <code>let</code>, with "borrow kind" read</p>



<a name="215383657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383657">(Nov 02 2020 at 21:46)</a>:</h4>
<p>I wonder how much will break if we do that ;)</p>



<a name="215383682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383682">(Nov 02 2020 at 21:47)</a>:</h4>
<p>(I don't think it should break much, but we may want to add a distinct sort of callback)</p>



<a name="215383701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383701">(Nov 02 2020 at 21:47)</a>:</h4>
<p>but the idea is that we could say <code>let _ = v</code> still captures <code>v</code>, that is considered "as if" we were to read <code>v</code></p>



<a name="215383718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383718">(Nov 02 2020 at 21:47)</a>:</h4>
<p>this is then compatible with the older code as well</p>



<a name="215383729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383729">(Nov 02 2020 at 21:47)</a>:</h4>
<p>(i.e., for <code>move</code> closures)</p>



<a name="215383753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383753">(Nov 02 2020 at 21:48)</a>:</h4>
<p>but it will make it easier to adapt the MIR builder and so forth</p>



<a name="215383765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383765">(Nov 02 2020 at 21:48)</a>:</h4>
<p>Okay yes that's what I was thinking. I was thinking more like we can set a flag so that clippy can turn off those callbacks</p>



<a name="215383809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383809">(Nov 02 2020 at 21:48)</a>:</h4>
<p>I'd prefer a distinct callback</p>



<a name="215383813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383813">(Nov 02 2020 at 21:48)</a>:</h4>
<p>then a flag</p>



<a name="215383821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383821">(Nov 02 2020 at 21:48)</a>:</h4>
<p>flags are confusing:)</p>



<a name="215383829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383829">(Nov 02 2020 at 21:48)</a>:</h4>
<p>Okay that works too I guess</p>



<a name="215383847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383847">(Nov 02 2020 at 21:48)</a>:</h4>
<p>but clippy can just leave the callback empty</p>



<a name="215383891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383891">(Nov 02 2020 at 21:48)</a>:</h4>
<p>it seems like it would be quite a lot of work to rejigger MIR construction</p>



<a name="215383896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383896">(Nov 02 2020 at 21:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215383498">said</a>:</p>
<blockquote>
<p>but <code>let _ = v</code> doesn't</p>
</blockquote>
<p>this is interesting</p>



<a name="215383936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383936">(Nov 02 2020 at 21:49)</a>:</h4>
<p>yeah, I'm not sure what I think the <em>ideal</em> behavior would be</p>



<a name="215383944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383944">(Nov 02 2020 at 21:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215383891">said</a>:</p>
<blockquote>
<p>it seems like it would be quite a lot of work to rejigger MIR construction</p>
</blockquote>
<p>Yeah I wasn't sure if it will work so I decided to discuss before I make a mess there lol</p>



<a name="215383966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215383966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215383966">(Nov 02 2020 at 21:49)</a>:</h4>
<p>but I think you can make a "decent case" for <code>let _ = v</code> capturing <code>v</code></p>



<a name="215384041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384041">(Nov 02 2020 at 21:50)</a>:</h4>
<p>however it's a bit unfortunate for there to be some asymmetry with what the borrow check considers a "use"</p>



<a name="215384048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384048">(Nov 02 2020 at 21:50)</a>:</h4>
<p>still, I'm inclined to just accept that :)</p>



<a name="215384054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384054">(Nov 02 2020 at 21:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215383966">said</a>:</p>
<blockquote>
<p>but I think you can make a "decent case" for <code>let _ = v</code> capturing <code>v</code></p>
</blockquote>
<p>I feel like the easiest argumentis back compat</p>



<a name="215384055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384055">(Nov 02 2020 at 21:50)</a>:</h4>
<p>(at worst, leave it as a FIXME)</p>



<a name="215384062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384062">(Nov 02 2020 at 21:50)</a>:</h4>
<p>yes, back-compat is part of it</p>



<a name="215384083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384083">(Nov 02 2020 at 21:50)</a>:</h4>
<p>I can also imagine that there is existing code for example that does <code>let _ = v</code> with a move closure to force a capture.</p>



<a name="215384112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384112">(Nov 02 2020 at 21:50)</a>:</h4>
<p>...maybe not... :) but plausible</p>



<a name="215384289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384289">(Nov 02 2020 at 21:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215384083">said</a>:</p>
<blockquote>
<p>I can also imagine that there is existing code for example that does <code>let _ = v</code> with a move closure to force a capture.</p>
</blockquote>
<p>Yeah it's used in 3 tests, tho those are fixable by just changing <code>_</code> to <code>_x</code></p>



<a name="215384375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384375">(Nov 02 2020 at 21:53)</a>:</h4>
<p>right</p>



<a name="215384376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384376">(Nov 02 2020 at 21:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215383440">said</a>:</p>
<blockquote>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">v</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="o">*</span><span class="n">p</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
</blockquote>
<p>Why do we process the borrow here but not when it's a move. (I tried it with a string and same result).</p>



<a name="215384392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384392">(Nov 02 2020 at 21:53)</a>:</h4>
<p>but that's the non-back-compat part :)</p>



<a name="215384415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384415">(Nov 02 2020 at 21:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215384376">said</a>:</p>
<blockquote>
<p>Why do we process the borrow here but not when it's a move. (I tried it with a string and same result).</p>
</blockquote>
<p>answer: we still <strong>evaluate</strong> the right hand side to make a temporary</p>



<a name="215384417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384417">(Nov 02 2020 at 21:53)</a>:</h4>
<p>i.e., <code>&amp;v</code> is not a place expression</p>



<a name="215384429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384429">(Nov 02 2020 at 21:53)</a>:</h4>
<p>so we have to evaluate it to get a value</p>



<a name="215384435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384435">(Nov 02 2020 at 21:53)</a>:</h4>
<p>and it's the <em>evaluation</em> that triggers the read</p>



<a name="215384452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384452">(Nov 02 2020 at 21:54)</a>:</h4>
<p>but <code>let _ = v</code>, the <code>v</code> is a place expression, so we can just match against <em>that place</em></p>



<a name="215384509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384509">(Nov 02 2020 at 21:54)</a>:</h4>
<p>put another way, if you did <code>let ref p = v</code>, that is equivalent to <code>let p = &amp;v</code></p>



<a name="215384538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384538">(Nov 02 2020 at 21:54)</a>:</h4>
<p>but <code>let ref p = &amp;v</code> is going to be like <code>let tmp = &amp;v; let p = &amp;tmp;</code></p>



<a name="215384546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384546">(Nov 02 2020 at 21:54)</a>:</h4>
<p>not sure if that helps :)</p>



<a name="215384602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384602">(Nov 02 2020 at 21:55)</a>:</h4>
<p>(ref patterns, while semi-deprecated, are one of the easiest ways to illustrate the difference between a place expression and not...)</p>



<a name="215384640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384640">(Nov 02 2020 at 21:55)</a>:</h4>
<p>I think it sort of makes sense</p>



<a name="215384746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384746">(Nov 02 2020 at 21:56)</a>:</h4>
<p>(remember: a "place expression" is one that names some place in memory that could be assigned to; also called an lvalue sometimes)</p>



<a name="215384768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384768">(Nov 02 2020 at 21:56)</a>:</h4>
<p>so like <code>&amp;v</code> is not a "place in memory", it's a value, much like <code>1 + 2</code></p>



<a name="215384774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384774">(Nov 02 2020 at 21:56)</a>:</h4>
<p>but <code>v</code> is a place in memory</p>



<a name="215384833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384833">(Nov 02 2020 at 21:57)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215384746">said</a>:</p>
<blockquote>
<p>(remember: a "place expression" is one that names some place in memory that could be assigned to; also called an lvalue sometimes)</p>
</blockquote>
<p>Yeah I think this really helps.</p>



<a name="215384856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384856">(Nov 02 2020 at 21:57)</a>:</h4>
<p>Interestingly you can't use _ with <code>ref</code></p>



<a name="215384884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215384884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215384884">(Nov 02 2020 at 21:57)</a>:</h4>
<p>So I was trying to validate if that would force a read</p>



<a name="215385384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215385384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215385384">(Nov 02 2020 at 22:01)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215384856">said</a>:</p>
<blockquote>
<p>Interestingly you can't use _ with <code>ref</code></p>
</blockquote>
<p>yeah <code>ref</code> has to be attachd to a binding name like <code>x</code> or <code>_x</code></p>



<a name="215385391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215385391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215385391">(Nov 02 2020 at 22:01)</a>:</h4>
<p><code>_</code> means "ignore"</p>



<a name="215385408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215385408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215385408">(Nov 02 2020 at 22:01)</a>:</h4>
<p><code>_x</code> means "bind to an unused variable"</p>



<a name="215385414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215385414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215385414">(Nov 02 2020 at 22:02)</a>:</h4>
<p>subtle distinction</p>



<a name="215385420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215385420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215385420">(Nov 02 2020 at 22:02)</a>:</h4>
<p>Yeah, I guess you can't have 2 patterns together</p>



<a name="215385425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215385425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215385425">(Nov 02 2020 at 22:02)</a>:</h4>
<p>(arguably too subtle)</p>



<a name="215385561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215385561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215385561">(Nov 02 2020 at 22:03)</a>:</h4>
<p>I feel it's common in some other languages (scala IIRC) to use _ as a reserved expression</p>



<a name="215498660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215498660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215498660">(Nov 03 2020 at 19:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215383651">said</a>:</p>
<blockquote>
<p>is to modify the <code>ExprUseVisitor</code> to add a <code>borrow</code> callback on the initializer of a <code>let</code>, with "borrow kind" read</p>
</blockquote>
<p>So if we have <code>let &lt;&gt;  = x</code> , we want to indicate a read for <code>x</code>. </p>
<p>If I understand correctly we want to modify this <a href="https://github.com/sexxi-goose/rust/blob/master/compiler/rustc_typeck/src/expr_use_visitor.rs#L353">https://github.com/sexxi-goose/rust/blob/master/compiler/rustc_typeck/src/expr_use_visitor.rs#L353</a></p>
<p>to essentially <code>borrow(init_place, ImmBorrow)</code> but via different API. (essentially indicating that it's being read), regardless of the lhs of the let?</p>
<p>I think that will limit the amount of disjoint capture we can do with destructure patterns.</p>



<a name="215498847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215498847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215498847">(Nov 03 2020 at 19:19)</a>:</h4>
<p>So the different cases we have are: </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w">  </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">;</span><span class="w">  </span><span class="c1">// 1</span>
<span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">tuple</span><span class="p">;</span><span class="w"> </span><span class="c1">// 2</span>
<span class="kd">let</span><span class="w"> </span><span class="n">Point</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">x</span>: <span class="nc">_</span><span class="p">,</span><span class="w"> </span><span class="n">y</span>: <span class="nc">_</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">point</span><span class="p">;</span><span class="w"> </span><span class="c1">// 3</span>

<span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">t1</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">tuple</span><span class="p">;</span><span class="w"> </span><span class="c1">// 4</span>
<span class="kd">let</span><span class="w"> </span><span class="n">Point</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">x</span>: <span class="nc">x</span><span class="p">,</span><span class="w"> </span><span class="n">y</span>: <span class="nc">_</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">point</span><span class="p">;</span><span class="w"> </span><span class="c1">// 5</span>
</code></pre></div>



<a name="215499037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215499037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215499037">(Nov 03 2020 at 19:20)</a>:</h4>
<p>It makes sense for 1 to completely read the variable. But if in 4, 5 we are providing precise capture it makes sense for 2 and 3 to capture nothing.</p>



<a name="215513382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215513382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215513382">(Nov 03 2020 at 21:39)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> that's a good point. I am not sure I had considered those full repercussions.</p>



<a name="215513399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215513399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215513399">(Nov 03 2020 at 21:39)</a>:</h4>
<p>I guess we could do something quite special to handle the case where it's a distinct callback</p>



<a name="215513414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215513414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215513414">(Nov 03 2020 at 21:39)</a>:</h4>
<p>But it's worth thinking about what it would take to refactor MIR building and "do this properly"</p>



<a name="215513478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215513478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215513478">(Nov 03 2020 at 21:40)</a>:</h4>
<p>After having thought about it, I personally don't think this a problem we should be solving in ExprUseVisitor</p>



<a name="215514244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215514244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215514244">(Nov 03 2020 at 21:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215499037">said</a>:</p>
<blockquote>
<p>It makes sense for 1 to completely read the variable. But if in 4, 5 we are providing precise capture it makes sense for 2 and 3 to capture nothing.</p>
</blockquote>
<p>mostly because of this^</p>
<p>I feel the current implementation keeps 2-3 consistent with 4-5.</p>



<a name="215514312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215514312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215514312">(Nov 03 2020 at 21:51)</a>:</h4>
<p>I think at least in the case of 2-3 not capturing tuple/point is part of enabling 2229, rather than breaking backcompat.</p>



<a name="215514453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215514453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215514453">(Nov 03 2020 at 21:53)</a>:</h4>
<p>Another interesting example would be arrays </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">some_arr</span><span class="p">;</span><span class="w"> </span><span class="c1">// 1</span>

<span class="kd">let</span><span class="w"> </span><span class="p">[</span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="n">d</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">some_arr</span><span class="p">;</span><span class="w"> </span><span class="c1">// 2</span>

<span class="kd">let</span><span class="w"> </span><span class="p">[</span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">some_arr</span><span class="p">;</span><span class="w"> </span><span class="c1">// 3</span>
</code></pre></div>
<p>Since arrays are completely captured, it kind of makes sense for all of the three to be equivalent i.e. capture some_arr entirely.</p>



<a name="215578991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215578991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215578991">(Nov 04 2020 at 13:23)</a>:</h4>
<p>So the problrm with MIR building (and THIR) is that you can have variables that appear in thie HIR but which are not ultimately going to be used</p>



<a name="215581995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215581995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215581995">(Nov 04 2020 at 13:48)</a>:</h4>
<p>I guess what this means is that we would need to introduce some way to represent an upvar that was <em>not captured</em> -- a kind of "poison pill" expression</p>



<a name="215582010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215582010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215582010">(Nov 04 2020 at 13:48)</a>:</h4>
<p>such that if we wind up <em>actually trying to read from it</em> we get an error</p>



<a name="215582021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215582021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215582021">(Nov 04 2020 at 13:48)</a>:</h4>
<p>(a <code>span_bug</code>, presumably)</p>



<a name="215582082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215582082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215582082">(Nov 04 2020 at 13:48)</a>:</h4>
<p>that way when you have <code>let _ = x</code> and we don't wind up capturing <code>x</code>, we can still translate that <code>let</code> statement. The reference to <code>x</code> would become a reference to <code>UncapturedUpvar(x)</code> or something</p>



<a name="215582118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215582118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215582118">(Nov 04 2020 at 13:49)</a>:</h4>
<p>the problem is that then, in MIR building, we'd have to convert <code>UncapturedUpvar</code> into a place</p>



<a name="215582131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215582131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215582131">(Nov 04 2020 at 13:49)</a>:</h4>
<p>it's just that this place would never <em>actually</em> wind up in the MIR itself</p>



<a name="215582137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215582137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215582137">(Nov 04 2020 at 13:49)</a>:</h4>
<p>this is annoying</p>



<a name="215582151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215582151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215582151">(Nov 04 2020 at 13:49)</a>:</h4>
<p>we could extend the concept of MIR place with "dummy place" or something but .. ugh</p>



<a name="215582248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215582248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215582248">(Nov 04 2020 at 13:50)</a>:</h4>
<p>so I guess this is why I was leaning towards -- <em>at least temporarily</em> -- ensuring that we capture every variable we reference</p>



<a name="215582257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215582257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215582257">(Nov 04 2020 at 13:50)</a>:</h4>
<p>but really I agree with you it's not the right behavior</p>



<a name="215582293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215582293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215582293">(Nov 04 2020 at 13:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215582118">said</a>:</p>
<blockquote>
<p>the problem is that then, in MIR building, we'd have to convert <code>UncapturedUpvar</code> into a place</p>
</blockquote>
<p>of course we <em>could</em> generate a place that would just be patently <em>wrong</em>, such as the return place</p>



<a name="215582302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215582302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215582302">(Nov 04 2020 at 13:50)</a>:</h4>
<p>I'm not super keen on that either</p>



<a name="215620676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215620676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215620676">(Nov 04 2020 at 18:14)</a>:</h4>
<p>Why do we keep let statements that introduce 0 bindings in THIR/MIR?</p>



<a name="215620789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215620789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215620789">(Nov 04 2020 at 18:15)</a>:</h4>
<p>Nvm, if someone has <code>let _ = init_with_side_effs(capture_var)</code>, or <br>
<code>let _ = { print(...); capture_var }</code></p>



<a name="215620913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215620913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215620913">(Nov 04 2020 at 18:16)</a>:</h4>
<p>Well something more useful that this but regardless these are valid rust let statements, which require the assigned place to be evaluated</p>



<a name="215638908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215638908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215638908">(Nov 04 2020 at 20:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215620789">said</a>:</p>
<blockquote>
<p>Nvm, if someone has <code>let _ = init_with_side_effs(capture_var)</code>, or <br>
<code>let _ = { print(...); capture_var }</code></p>
</blockquote>
<p>I was trying to go for capture_path more than captured_var. Also this is interesting we don't currently have test cases where we call a function with a precise capture as a function argument.</p>



<a name="215642883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215642883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215642883">(Nov 04 2020 at 21:20)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> there are also interesting cases like </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">y</span><span class="p">)</span><span class="w"></span>
</code></pre></div>
<p>although I guess that this will actually construct the tuple first</p>



<a name="215642919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215642919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215642919">(Nov 04 2020 at 21:21)</a>:</h4>
<p>my initial thought was that it would be very hard to detect the cases where we can just "drop the let statement altogether"</p>



<a name="215642922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215642922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215642922">(Nov 04 2020 at 21:21)</a>:</h4>
<p>but now I am wondering if that's true</p>



<a name="215642934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215642934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215642934">(Nov 04 2020 at 21:21)</a>:</h4>
<p>the right-hand-side has to be a place expression</p>



<a name="215642946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215642946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215642946">(Nov 04 2020 at 21:21)</a>:</h4>
<p>and the pattern has to have no bindings</p>



<a name="215642968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215642968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215642968">(Nov 04 2020 at 21:21)</a>:</h4>
<p>well</p>



<a name="215642993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215642993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215642993">(Nov 04 2020 at 21:22)</a>:</h4>
<p>yeah I guess if it's a <code>let</code>, then the pattern has to be irrefutable, so it can't have "tests"</p>



<a name="215643048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643048">(Nov 04 2020 at 21:22)</a>:</h4>
<p>so probably just any pattern with no bindings and a right-hand-side that is a place expression can just be ignored--well-- interesting--</p>



<a name="215643058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643058">(Nov 04 2020 at 21:22)</a>:</h4>
<p>overloaded deref and indexing may make that less true :)</p>



<a name="215643074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643074">(Nov 04 2020 at 21:22)</a>:</h4>
<p>i.e., <code>let _ = *x</code> where <code>*x</code> is overloaded</p>



<a name="215643093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643093">(Nov 04 2020 at 21:22)</a>:</h4>
<p>but I think that this will be registered as a "read" of <code>x</code> in any case</p>



<a name="215643134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643134">(Nov 04 2020 at 21:23)</a>:</h4>
<p>I guess I am now thinking that we should detect this case and just drop such <code>let</code> statements from the THIR, but we'll have to craft the conditions "just right"</p>



<a name="215643154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643154">(Nov 04 2020 at 21:23)</a>:</h4>
<p>I wonder if we can rely on the fact that we don't have any captured variable for the upvar</p>



<a name="215643174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643174">(Nov 04 2020 at 21:23)</a>:</h4>
<p>e.g., check if the right-hand-side is a place expression whose root variable is not captured</p>



<a name="215643183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643183">(Nov 04 2020 at 21:23)</a>:</h4>
<p>if so, assert that the left-hand-side has no bindings</p>



<a name="215643189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643189">(Nov 04 2020 at 21:23)</a>:</h4>
<p>and skip the let</p>



<a name="215643192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643192">(Nov 04 2020 at 21:23)</a>:</h4>
<p>something like that</p>



<a name="215643264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643264">(Nov 04 2020 at 21:24)</a>:</h4>
<p>Yeah it's going to be a bit tricky.</p>



<a name="215643285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643285">(Nov 04 2020 at 21:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215643174">said</a>:</p>
<blockquote>
<p>e.g., check if the right-hand-side is a place expression whose root variable is not captured</p>
</blockquote>
<p>this might not be so tricky</p>



<a name="215643323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643323">(Nov 04 2020 at 21:24)</a>:</h4>
<p>it's a little bit more "linked" than I would like</p>



<a name="215643337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643337">(Nov 04 2020 at 21:24)</a>:</h4>
<p>in that we're assuming the upvar analysis code is correct</p>



<a name="215643349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643349">(Nov 04 2020 at 21:24)</a>:</h4>
<p>but the assertion helps there</p>



<a name="215643428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643428">(Nov 04 2020 at 21:25)</a>:</h4>
<p>/me still thinking</p>



<a name="215643595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215643595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215643595">(Nov 04 2020 at 21:26)</a>:</h4>
<p>I don't exactly know what would get captured in case of <code>let _ = (upvar1, upvar2)</code> with the new analysis. Because we have an Rvalue on the right side, which when evaluated might not find the Places it needs to evaluate correctly.</p>



<a name="215646583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215646583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215646583">(Nov 04 2020 at 21:57)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215643595">said</a>:</p>
<blockquote>
<p>I don't exactly know what would get captured in case of <code>let _ = (upvar1, upvar2)</code> with the new analysis. Because we have an Rvalue on the right side, which when evaluated might not find the Places it needs to evaluate correctly.</p>
</blockquote>
<p>Actually this works out fine </p>
<ul>
<li><a href="http://csclub.uwaterloo.ca/~a52arora/test_suite/tuple_rvalue.rs">http://csclub.uwaterloo.ca/~a52arora/test_suite/tuple_rvalue.rs</a></li>
<li><a href="http://csclub.uwaterloo.ca/~a52arora/test_suite/tuple_rvalue.rs.stderr">http://csclub.uwaterloo.ca/~a52arora/test_suite/tuple_rvalue.rs.stderr</a></li>
</ul>



<a name="215649121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215649121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215649121">(Nov 04 2020 at 22:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215643595">said</a>:</p>
<blockquote>
<p>I don't exactly know what would get captured in case of <code>let _ = (upvar1, upvar2)</code> with the new analysis. Because we have an Rvalue on the right side, which when evaluated might not find the Places it needs to evaluate correctly.</p>
</blockquote>
<p>yes, it should work out fine</p>



<a name="215649127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215649127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215649127">(Nov 04 2020 at 22:27)</a>:</h4>
<p>it'll treat the RHS as an expression to be evaluated</p>



<a name="215649450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215649450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215649450">(Nov 04 2020 at 22:31)</a>:</h4>
<p>Will it be fine to have some capture analysis code merged in before <code>let _ = x</code> patterns are completely handled? The last PR before that has been r+'d <a href="https://github.com/rust-lang/rust/pull/78662">https://github.com/rust-lang/rust/pull/78662</a>. </p>
<p>Benefits would be:</p>
<ul>
<li>Get some feedback since it's mostly been us who have looked at the code, especially since the analysis being correct is important for <code>let _ = x</code> handling</li>
<li>Saves us from merge conflicts <span aria-label="joy" class="emoji emoji-1f602" role="img" title="joy">:joy:</span></li>
</ul>



<a name="215649783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215649783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215649783">(Nov 04 2020 at 22:34)</a>:</h4>
<p>Also <code>let _ = x</code> only breaks with the feature gate enabled</p>



<a name="215666400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215666400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215666400">(Nov 05 2020 at 02:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215643174">said</a>:</p>
<blockquote>
<p>e.g., check if the right-hand-side is a place expression whose root variable is not captured</p>
</blockquote>
<p>This might be trickly I think we want the right hand side to be place that isn't captured. </p>
<p>Consider</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">Point</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">   </span><span class="n">x</span>: <span class="kt">i32</span><span class="p">,</span><span class="w"></span>
<span class="w">   </span><span class="n">y</span>: <span class="kt">i32</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">Rectangle</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">   </span><span class="n">top_left</span>: <span class="nc">Point</span><span class="p">,</span><span class="w"></span>
<span class="w">   </span><span class="n">bottom_right</span>: <span class="nc">Point</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="n">p1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Point</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">..</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">p2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Point</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">..</span><span class="w"> </span><span class="p">};</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="n">rect</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Rectange</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">p1</span><span class="p">,</span><span class="w"> </span><span class="n">p2</span><span class="w"> </span><span class="p">};</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">   </span><span class="kd">let</span><span class="w"> </span><span class="n">Point</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">x</span>: <span class="nc">_</span><span class="p">,</span><span class="w"> </span><span class="n">y</span>: <span class="nc">_</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">top_left</span><span class="p">;</span><span class="w">  </span><span class="c1">// L1, Nothing is captured</span>
<span class="w">   </span><span class="kd">let</span><span class="w"> </span><span class="n">Point</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">x</span>: <span class="nc">_</span><span class="p">,</span><span class="w"> </span><span class="n">y</span>: <span class="nc">y</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">bottom_right</span><span class="p">;</span><span class="w"> </span><span class="c1">// L2, p.bottom_right.y is captured</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Now L1 still doesn't compile since the place on the right isn't captured. </p>
<p>I didn't really see <code>Place</code> being used in THIR, if we have to use hir::Place, then we might need to bring in MemCat to determine the Place properly. If we need to use mir::Place then we would need to determine equivalance relation b/w mir and hir Place.</p>



<a name="215715807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215715807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215715807">(Nov 05 2020 at 14:09)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> I think it is fine to have <code>let _ = x</code> ICE or otherwise break, so long as it is confined to the feature gate, we can just file a FIXME issue to address it</p>



<a name="215716193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215716193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215716193">(Nov 05 2020 at 14:13)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> hmm, when I said "if the root variable is captured", I think I was imagining that as a temporary solution, i.e., only for the case where we have not yet implemented 'minimal capture'. Once we do implement minimal capture, the test would indeed be more complicated, but the same premise could be applied. Basically I think what I am proposing is that we would modify the THIR-construction code so that when you lower a HIR expression to THIR, you get back a <code>Result</code>, essentially, with one possible outcome being "unrepresentable". This would be the case for an upvar that was not captured.</p>
<p>The hope is that most of the time we can just <code>unwrap</code> the result (well, we might make a dedicated helper so that we get a better ICE, but that's the idea), because it should never happen. However, <strong>in the case of <code>let x = initializer</code> specifically</strong>, if the initializer comes back as unrepresentable, then we can assert that there are no bindings in the LHS.</p>



<a name="215716230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215716230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215716230">(Nov 05 2020 at 14:13)</a>:</h4>
<p>I guess though that we have to think indeed about cases where the initializer is "partly representable"</p>



<a name="215716260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215716260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215716260">(Nov 05 2020 at 14:13)</a>:</h4>
<p>This is a bit tricky, I hadn't thought this part through</p>



<a name="215716332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215716332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215716332">(Nov 05 2020 at 14:14)</a>:</h4>
<p>well, hmm, OK I'm paging this back in</p>



<a name="215716349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215716349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215716349">(Nov 05 2020 at 14:14)</a>:</h4>
<p>I guess we should just discuss this in our meeting today :)</p>



<a name="215716362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215716362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215716362">(Nov 05 2020 at 14:14)</a>:</h4>
<p>I have some other things to do right now</p>



<a name="215741916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215741916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215741916">(Nov 05 2020 at 17:01)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> joining</p>



<a name="215803487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215803487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215803487">(Nov 06 2020 at 03:45)</a>:</h4>
<p>Leaving this here so that we don't lose track: <a href="https://hackmd.io/aD41lqdMSmG7mvHJYt-mtg">https://hackmd.io/aD41lqdMSmG7mvHJYt-mtg</a></p>



<a name="215809480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215809480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215809480">(Nov 06 2020 at 06:10)</a>:</h4>
<p>We had briefly mentioned this earlier but <code>let _ = x</code> will have effect on closure -&gt; fn coercion</p>



<a name="215809496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215809496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215809496">(Nov 06 2020 at 06:11)</a>:</h4>
<p>I think that we would have to do the obligation thing we had previously discussed since we can't decide on the number of captures until typeck is done. (Right now it depends on upvars mentioned)</p>



<a name="215811370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215811370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215811370">(Nov 06 2020 at 06:58)</a>:</h4>
<p>(deleted)</p>



<a name="215882782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215882782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215882782">(Nov 06 2020 at 18:08)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> Yes, although I think that can live as a FIXME -- using "upvars mentioned" for this check feels acceptable to me.</p>



<a name="215883026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/215883026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#215883026">(Nov 06 2020 at 18:10)</a>:</h4>
<p>btw do we want this <a href="https://github.com/rust-lang/rust/issues/72457">#72457</a>? I ended up implementing it before I realised that it would need to be changed in the near future. (It's sub 20 LOC)</p>



<a name="216052036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216052036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216052036">(Nov 09 2020 at 08:00)</a>:</h4>
<p>(deleted)</p>



<a name="216091119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216091119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216091119">(Nov 09 2020 at 14:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/let.20_.20.3D.20x.20pattern/near/215883026">said</a>:</p>
<blockquote>
<p>btw do we want this <a href="https://github.com/rust-lang/rust/issues/72457">#72457</a>? I ended up implementing it before I realised that it would need to be changed in the near future. (It's sub 20 LOC)</p>
</blockquote>
<p>seems useful</p>



<a name="216307956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216307956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216307956">(Nov 11 2020 at 04:58)</a>:</h4>
<p>I think this could exaggerate the <code>let _ = x</code> issue.  <a href="https://github.com/rust-lang/rust/pull/71156">https://github.com/rust-lang/rust/pull/71156</a></p>
<p>Essentially any pattern that used <code>_</code> will have an issue if  I understand correctly</p>



<a name="216308111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216308111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216308111">(Nov 11 2020 at 05:02)</a>:</h4>
<p>Nvm, if that is correct <a href="https://github.com/rust-lang/rust/pull/71156#issuecomment-725195572">https://github.com/rust-lang/rust/pull/71156#issuecomment-725195572</a> then we can't capture disjoint fields there, because the first line will make it look like <code>tup</code> is used in entirety</p>



<a name="216310795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216310795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216310795">(Nov 11 2020 at 06:06)</a>:</h4>
<p>Actually got a reply on that thread, looks like it won't affect us <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="216496899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216496899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216496899">(Nov 12 2020 at 17:00)</a>:</h4>
<p>Joining in 2 mins</p>



<a name="216497258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216497258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216497258">(Nov 12 2020 at 17:03)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> be there in 2 minutes</p>



<a name="216497268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216497268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216497268">(Nov 12 2020 at 17:03)</a>:</h4>
<p>sorry running a bit late</p>



<a name="216497685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216497685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216497685">(Nov 12 2020 at 17:06)</a>:</h4>
<p>no problem</p>



<a name="216498432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216498432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216498432">(Nov 12 2020 at 17:12)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> ok</p>



<a name="216503411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216503411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216503411">(Nov 12 2020 at 17:51)</a>:</h4>
<p><a href="/user_uploads/4715/vbzg7LQDtytHWlJYJAS6gNnD/image.png">image.png</a> <br>
read in match</p>
<div class="message_inline_image"><a href="/user_uploads/4715/vbzg7LQDtytHWlJYJAS6gNnD/image.png" title="image.png"><img src="/user_uploads/4715/vbzg7LQDtytHWlJYJAS6gNnD/image.png"></a></div>



<a name="216516185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216516185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216516185">(Nov 12 2020 at 19:29)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span>  can you upload the video from today before the weekend?</p>



<a name="216521197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216521197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216521197">(Nov 12 2020 at 20:13)</a>:</h4>
<p>yep</p>



<a name="216530156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/216530156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#216530156">(Nov 12 2020 at 21:20)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> <a href="https://youtu.be/BvPIpfa27TY">https://youtu.be/BvPIpfa27TY</a> (not yet fully uploaded)</p>
<div class="youtube-video message_inline_image"><a data-id="BvPIpfa27TY" href="https://youtu.be/BvPIpfa27TY"><img src="https://i.ytimg.com/vi/BvPIpfa27TY/default.jpg"></a></div>



<a name="217094858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/217094858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#217094858">(Nov 18 2020 at 04:18)</a>:</h4>
<p>So for <a href="https://github.com/rust-lang/rust/pull/79149">https://github.com/rust-lang/rust/pull/79149</a> I had name <a href="https://github.com/rust-lang/rust/issues/30">#30</a> when I copied the PR from our fork to rust-lang. </p>
<p>Apparantly chaning the name makes the PR not mergable (on bors build queue). Can you r+ it again? Thanks</p>



<a name="217103558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/217103558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#217103558">(Nov 18 2020 at 07:34)</a>:</h4>
<p>nvm</p>



<a name="217145706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/let%20_%20%3D%20x%20pattern/near/217145706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/let.20_.20.3D.20x.20pattern.html#217145706">(Nov 18 2020 at 15:02)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> ok, everything is good there?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>